#!/env/bin/python
# coding:utf-8

import time
import unittest
import HTMLTestRunner
from functions import date_n,id,name,css,xpath,js,return_driver,open_Url
from functions import read_excel
from functions import log
from searchTickets import search_tickets

#search_tickets("北京","郑州",3)
class book_tickets(unittest.TestCase):
    def setUp(self):
        self.driver = return_driver()
        self.driver.maximize_window()

    def test_ctrip_tickets(self):
        log("Read Excel Files to get test data.")
        dict = read_excel("test_data.xlsx",0)
        print(dict[0][0],dict[0][1])

        log("Begin to search tickets!")
        search_tickets(dict[0][0],dict[0][1],2)
        log("End to search tickets!")
        log("Begin to get driver object.")
        driver = return_driver()
        time.sleep(3)

        log("Click book button:")

    def tearDown(self):
        self.driver.quit()

if __name__ == '__main__':
    suite = unittest.TestSuite()
    suite.addTest(book_tickets("test_ctrip_tickets"))
    file_name = "D:\\MyDoc\\python\\Selenium自动化\\携程\\ctrip_tickets_reporter.html"

    fp = open(file_name, 'wb')

    runner = HTMLTestRunner.HTMLTestRunner(stream=fp, title="Test_Report_Portal", description="Report_Description")
    runner.run(suite)
    fp.close()
    print("测试完成")





